<template>
  <div>
    <van-grid clickable :column-num="3">
      <van-grid-item v-for="(item ,index) in appList" :key="index" @click="itemClick(index)">
        <van-icon :name="item.icon" :color="item.color" size="2rem" />
        <span class="app-title">{{item.name}}</span>
      </van-grid-item>
    </van-grid>
  </div>
</template>
<script>
import api from "../../../tools/api";
import NJS from "../../../tools/nhjssdk";
export default {
  name: "AppList",
  data() {
    return {
      appList: [
        { icon: "enlarge", color: "#f44336", name: "扫一扫" },
        { icon: "records", color: "#673ab7", name: "扫码记录" },
        // { icon: "points", color: "#9c27b0", name: "网络硬盘" },
        // { icon: "friends-o", color: "#673ab7", name: "通讯录" }
      ]
    };
  },

  methods: {
    itemClick(index) {
      let item = this.appList[index];
      console.log(JSON.stringify(item))
      if(item.name=="扫一扫"){
         //页面初始化
    NJS.app({
      action: "scanCode",
      callback: function(res) {
        let result = JSON.parse(res.result);
        console.log("scanCode result"+JSON.stringify(result))
      }
    });
      }
      // this.$emit("itemClick");
      // this.$router.push("/wgrk");
      // api.ajax({
      //   methodName: "role/getAll",
      //   data: {},
      //   s(code, res) {
          
      //   }
      // });
    }
  }
};
</script>
<style scoped>
.app-title {
  color: gray;
  margin-top: 10px;
}
</style>


